package logic

import (
	"context"
	"goodsrpc/mysql"

	"goodsrpc/goods"
	"goodsrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type OrderInquiryLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewOrderInquiryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OrderInquiryLogic {
	return &OrderInquiryLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *OrderInquiryLogic) OrderInquiry(in *goods.OrderInquiryRequest) (*goods.OrderInquiryResponse, error) {
	// todo: add your logic here and delete this line
	var o mysql.Order
	mysql.DB.Where("id = ?", in.Id).Find(&o)

	return &goods.OrderInquiryResponse{
		OrderNo:  o.OrderNo,
		HouseId:  o.HouseId,
		UserId:   o.UserId,
		Quantity: o.Quantity,
		Price:    uint64(o.Price),
		State:    o.State,
	}, nil
}
